<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./template.xhtml">

            <ui:define name="title">
                Thống kê KQXS
            </ui:define>

            <ui:define name="content">
                <h:form>
                    <p:panel>
                        <h:panelGrid columns="2">
                            Chọn tỉnh:
                            <p:selectOneMenu value="#{lotteryStatBean.selectedProvince}">
                                <f:selectItems value="#{lotteryStatBean.provinceMap}"/>
                            </p:selectOneMenu>
                            <p:commandButton value="Xem kết quả" action="#{lotteryStatBean.search()}" update=":tableForm"/>
                        </h:panelGrid>
                    </p:panel>
                </h:form>
                <br/>
                <h:form id="tableForm">
                    <p:dataTable rendered="#{lotteryStatBean.list != null and lotteryStatBean.list.size() > 0}"
                                 id="table" value="#{lotteryStatBean.list}" var="item" resizableColumns="true"
                                 paginator="#{lotteryStatBean.list.size() >100}" rows="100">

                        <p:column headerText="Bộ số" sortBy="#{item.number}">
                            #{item.number}
                        </p:column>
                        <p:column headerText="Ngày ăn">
                            #{item.winDatesStr}
                        </p:column>
                        <p:column headerText="Số ngày ăn" sortBy="#{item.totalWin}">
                            #{item.totalWin}
                        </p:column>
                        <p:column headerText="Ngày ăn cuối" sortBy="#{item.lastWinDate}">
                            <h:outputText value="#{item.lastWinDate}">
                                <f:convertDateTime pattern="dd/MM/yyyy" timeZone="Asia/Saigon"/>
                            </h:outputText>
                        </p:column>
                    </p:dataTable>

                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
